/*
 * @Description: 
 * @Version: 2.0
 * @Autor: liuwei
 * @Date: 2021-05-29 09:38:57
 * @LastEditors: liuwei
 * @LastEditTime: 2021-05-29 09:40:31
 */
class Dep {
  constructor () {
    // 存储所有的观察者
    this.subs = []
  }

  // 添加观察者
  addSub (sub) {
    if (sub && sub.update) {
      this.subs.push(sub)
    }
  }

  // 发送通知
  notify () {
    this.subs.forEach(sub => {
      sub.update()
    })
  }
}